package org.eproject.core.well.tag;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.eproject.core.hibernate.pojo.SHandle;

@SuppressWarnings("serial")
public class Showbutton extends TagSupport{
	private List<SHandle> handle;
	private JspWriter out;
	public int doStartTag() throws JspException {
		HttpSession session = this.pageContext.getSession();
		out = this.pageContext.getOut();
		handle = (List)session.getAttribute("handle");
		if(handle != null&&handle.size()>0){
			try {
				out.println("<table name='usertable'><tr>");
				for(SHandle s : handle){
					StringBuilder sub = new StringBuilder("sub(");
					sub.append("'"+s.getHpath()+"',");
					sub.append("'"+s.getHtarget()+"')");
					out.print("<td>");
					out.print("<input type=button class='BigButton' value='"+s.getHname()+"' onClick=javascript:"+sub.toString()+";>");
					out.print("</td>");
				}
				out.println("</table>");
				out.flush();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return SKIP_BODY;
	}
}
